﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Lực cản môi trường</title>
<meta name="GENERATOR" content="WinCHM">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

</head>

<body>
<P><FONT face=Courier ><A 
href="http://stackoverflow.com/questions/8295490/cocos2d-box2d-coin-based-game-gravity-on-z-axis-coin-floating">http://stackoverflow.com/questions/8295490/cocos2d-box2d-coin-based-game-gravity-on-z-axis-coin-floating</A> </FONT></P>
<P 
style="BORDER-TOP-WIDTH: 0px; CLEAR: both; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 1em; WORD-SPACING: 0px; FONT: 14px/18px Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; VERTICAL-ALIGN: baseline; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; PADDING-TOP: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(255,255,255); TEXT-ALIGN: left; BORDER-RIGHT-WIDTH: 0px; WORD-WRAP: break-word; orphans: 2; widows: 2; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px; border-image: initial; background-origin: initial; background-clip: initial">Now 
I am working on carrom like game using cocos2d + Box2d. I set<SPAN 
class=Apple-converted-space>&nbsp;</SPAN><CODE 
style="BORDER-TOP-WIDTH: 0px; PADDING-RIGHT: 5px; PADDING-LEFT: 5px; BORDER-LEFT-WIDTH: 0px; FONT-SIZE: 14px; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 1px; MARGIN: 0px; VERTICAL-ALIGN: baseline; PADDING-TOP: 1px; FONT-FAMILY: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; BACKGROUND-COLOR: rgb(238,238,238); BORDER-RIGHT-WIDTH: 0px; border-image: initial; background-origin: initial; background-clip: initial">world 
gravity(0,0)</CODE>..to make gravity on z-axis. Is it proper or any other 
value?</P>
<P 
style="BORDER-TOP-WIDTH: 0px; CLEAR: both; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 1em; WORD-SPACING: 0px; FONT: 14px/18px Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; VERTICAL-ALIGN: baseline; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; PADDING-TOP: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(255,255,255); TEXT-ALIGN: left; BORDER-RIGHT-WIDTH: 0px; WORD-WRAP: break-word; orphans: 2; widows: 2; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px; border-image: initial; background-origin: initial; background-clip: initial">I 
set following value for coin striker body:</P><PRE style="BORDER-TOP-WIDTH: 0px; PADDING-RIGHT: 5px; OVERFLOW-Y: auto; PADDING-LEFT: 5px; BORDER-LEFT-WIDTH: 0px; OVERFLOW-X: auto; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 5px; MARGIN: 0px 0px 10px; WORD-SPACING: 0px; FONT: 14px/18px Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; VERTICAL-ALIGN: baseline; TEXT-TRANSFORM: none; WIDTH: auto; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; PADDING-TOP: 5px; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(255,255,255); TEXT-ALIGN: left; BORDER-RIGHT-WIDTH: 0px; orphans: 2; widows: 2; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px; border-image: initial; background-origin: initial; background-clip: initial; max-height: 600px"><CODE style="BORDER-TOP-WIDTH: 0px; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BORDER-LEFT-WIDTH: 0px; FONT-SIZE: 14px; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: baseline; PADDING-TOP: 0px; FONT-FAMILY: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; BACKGROUND-COLOR: rgb(238,238,238); BORDER-RIGHT-WIDTH: 0px; border-image: initial; background-origin: initial; background-clip: initial">Coin body: 
         density = 20.0f;
         friction = 0.4f;
         restitution = 0.6f;
         Shape Circle with radius - 15/PTM_RATIO

  Striker body: 
         density = 25.0f;
         friction = 0.6f;
         restitution = 0.3f;
         Shape Circle with radius - 15/PTM_RATIO</CODE></PRE>
<P 
style="BORDER-TOP-WIDTH: 0px; CLEAR: both; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 1em; WORD-SPACING: 0px; FONT: 14px/18px Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; VERTICAL-ALIGN: baseline; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; PADDING-TOP: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(255,255,255); TEXT-ALIGN: left; BORDER-RIGHT-WIDTH: 0px; WORD-WRAP: break-word; orphans: 2; widows: 2; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px; border-image: initial; background-origin: initial; background-clip: initial">Output 
is not smooth, when I apply<SPAN class=Apple-converted-space>&nbsp;</SPAN><CODE 
style="BORDER-TOP-WIDTH: 0px; PADDING-RIGHT: 5px; PADDING-LEFT: 5px; BORDER-LEFT-WIDTH: 0px; FONT-SIZE: 14px; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 1px; MARGIN: 0px; VERTICAL-ALIGN: baseline; PADDING-TOP: 1px; FONT-FAMILY: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; BACKGROUND-COLOR: rgb(238,238,238); BORDER-RIGHT-WIDTH: 0px; border-image: initial; background-origin: initial; background-clip: initial">ApplyLinearImpulse(force,position);</CODE></P>
<P 
style="BORDER-TOP-WIDTH: 0px; CLEAR: both; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 1em; WORD-SPACING: 0px; FONT: 14px/18px Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; VERTICAL-ALIGN: baseline; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; PADDING-TOP: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(255,255,255); TEXT-ALIGN: left; BORDER-RIGHT-WIDTH: 0px; WORD-WRAP: break-word; orphans: 2; widows: 2; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px; border-image: initial; background-origin: initial; background-clip: initial">Coin 
movement looks like floating in air....takes too much time to stop...</P>
<P 
style="BORDER-TOP-WIDTH: 0px; CLEAR: both; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 1em; WORD-SPACING: 0px; FONT: 14px/18px Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; VERTICAL-ALIGN: baseline; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; PADDING-TOP: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(255,255,255); TEXT-ALIGN: left; BORDER-RIGHT-WIDTH: 0px; WORD-WRAP: break-word; orphans: 2; widows: 2; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px; border-image: initial; background-origin: initial; background-clip: initial">Which 
value of coin and striker makes it look like real carom?</P>
<H2 
style="BORDER-TOP-WIDTH: 0px; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; WORD-SPACING: 0px; FONT: bold 22px/34px 'Trebuchet MS', 'Liberation Sans', 'DejaVu Sans', sans-serif; VERTICAL-ALIGN: baseline; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; PADDING-TOP: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(255,255,255); TEXT-ALIGN: left; BORDER-RIGHT-WIDTH: 0px; orphans: 2; widows: 2; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px; border-image: initial; background-origin: initial; background-clip: initial">Answer</H2>
<P 
style="BORDER-TOP-WIDTH: 0px; CLEAR: both; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 1em; WORD-SPACING: 0px; FONT: 14px/18px Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; VERTICAL-ALIGN: baseline; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; PADDING-TOP: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(255,255,255); TEXT-ALIGN: left; BORDER-RIGHT-WIDTH: 0px; WORD-WRAP: break-word; orphans: 2; widows: 2; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px; border-image: initial; background-origin: initial; background-clip: initial">The 
problem that you're having is that friction is only applied when two bodies are 
colliding. Since the coin is just floating in air, there's no resistance being 
applied. To fix this and apply a very rough approximation of air 
resistance,<SPAN class=Apple-converted-space>&nbsp;</SPAN><A 
style="BORDER-TOP-WIDTH: 0px; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BORDER-LEFT-WIDTH: 0px; FONT-SIZE: 14px; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: baseline; CURSOR: pointer; COLOR: rgb(74,107,130); PADDING-TOP: 0px; BACKGROUND-COLOR: transparent; BORDER-RIGHT-WIDTH: 0px; TEXT-DECORATION: none; border-image: initial; background-origin: initial; background-clip: initial" 
href="http://www.box2d.org/manual.html#_Toc258082973" rel=nofollow>you should 
set the<SPAN class=Apple-converted-space>&nbsp;</SPAN><CODE 
style="BORDER-TOP-WIDTH: 0px; PADDING-RIGHT: 5px; PADDING-LEFT: 5px; BORDER-LEFT-WIDTH: 0px; FONT-SIZE: 14px; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 1px; MARGIN: 0px; VERTICAL-ALIGN: baseline; PADDING-TOP: 1px; FONT-FAMILY: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; BACKGROUND-COLOR: rgb(238,238,238); BORDER-RIGHT-WIDTH: 0px; border-image: initial; background-origin: initial; background-clip: initial">linearDamping</CODE><SPAN 
class=Apple-converted-space>&nbsp;</SPAN>property of the body's 
definition</A>:</P><PRE style="BORDER-TOP-WIDTH: 0px; PADDING-RIGHT: 5px; OVERFLOW-Y: auto; PADDING-LEFT: 5px; BORDER-LEFT-WIDTH: 0px; OVERFLOW-X: auto; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 5px; MARGIN: 0px 0px 10px; WORD-SPACING: 0px; FONT: 14px/18px Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; VERTICAL-ALIGN: baseline; TEXT-TRANSFORM: none; WIDTH: auto; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; PADDING-TOP: 5px; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(255,255,255); TEXT-ALIGN: left; BORDER-RIGHT-WIDTH: 0px; orphans: 2; widows: 2; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px; border-image: initial; background-origin: initial; background-clip: initial; max-height: 600px"><CODE style="BORDER-TOP-WIDTH: 0px; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BORDER-LEFT-WIDTH: 0px; FONT-SIZE: 14px; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: baseline; PADDING-TOP: 0px; FONT-FAMILY: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; BACKGROUND-COLOR: rgb(238,238,238); BORDER-RIGHT-WIDTH: 0px; border-image: initial; background-origin: initial; background-clip: initial">bodyDef.linearDamping = 0.5f;
</CODE></PRE>
<P 
style="BORDER-TOP-WIDTH: 0px; CLEAR: both; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 1em; WORD-SPACING: 0px; FONT: 14px/18px Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; VERTICAL-ALIGN: baseline; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; PADDING-TOP: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(255,255,255); TEXT-ALIGN: left; BORDER-RIGHT-WIDTH: 0px; WORD-WRAP: break-word; orphans: 2; widows: 2; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px; border-image: initial; background-origin: initial; background-clip: initial">Try 
experimenting with different values until it looks right to 
you.</P></body>
</html>
